I am interested in timing a section of code in order to get execution time. Does anyone have experience in this type of debugging/optimization?
|
Re: Timing a section of code To measure small execution times you need to call a function multiple times and divide the time it took, by the number of executions. The number of times you need to execute the function however depends on the execution time of the function. You may need to call a string function 10000 times to get a measurable result, while you might need to call a function that performs a complex operation only once. The profiling.inc contains a function that will automatically determine how many times a function needs to be called, until the complete execution time is > 500ms that way you get a more stable result for functions that have very small execution times. The next thing is averaging results. Depending on the load of the computer you might want to make the measurement multiple times and take the average. That is also built into the profiling.inc. Last but not least, the DXL standard library prototype has an automatization for executing a profiling suite on set of library functions, so you can measure performance changes of library function long term. All in all it might be worth taking a look: http://sourceforge.net/projects/dxlstandardlib/ You should be able to download and run it, if there are any questions, do not hesitate to ask. Maybe that helps, regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Timing a section of code Cheers, |
Re: Timing a section of code
I imagine Mathias' approach is significantly precise and robust.
int TimeStart = getTickCount_(), TimeTotal
//for whatever my loop is
//{ Do stuff in the loop
//}
infoBox("Pause")
TimeTotal = (getTickCount_() - TimeStart)
print "Whatever execution time is " TimeTotal "msecs\n"
|